#pragma once

namespace lyz
{
	template<class Iterator, class Ref, class Ptr>
	struct ReverseIterator
	{
		typedef ReverseIterator<Iterator, Ref, Ptr> self;

		ReverseIterator(const Iterator& it)
			:cur(it)
		{

		}
		Iterator cur;

		self& operator++()
		{
			--cur;
			return *this;
		}
		self operator++(int)
		{
			Iterator tmp(cur);
			--cur;
			return tmp;
		}

		self& operator--()
		{
			++cur;
			return *this;
		}
		self operator--(int)
		{
			Iterator tmp(cur);
			++cur;
			return tmp;
		}

		Ref operator*()
		{
			Iterator tmp(cur);
			--tmp;
			return *tmp;
			//return *cur;
		}

		bool operator!=(const self& s)
		{
			return cur != s.cur;
		}

	};
}